package com.pwc.conversitonTool.soapui;

import java.io.StringReader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.Node;
import org.dom4j.io.SAXReader;
import org.junit.Test;

import com.eviware.soapui.model.iface.Request.SubmitException;
import com.pwc.conversionTool.soapUI.SoapUIClient;
import com.pwc.conversionTool.xml.XMLAttribute;
import com.pwc.conversionTool.xml.XMLFactory;
import com.pwc.conversionTool.xml.XMLNode;


public class xml {
	
	static String URLWorkDay = "https://wd2-impl-services1.workday.com/ccx/service/pwc_dpt1/Staffing/v25.0?wsdl";
	
	@Test
	public void TestXML() throws SubmitException, DocumentException {
		SoapUIClient client = new SoapUIClient();

		client.initialProject(URLWorkDay);

		HashMap<String, String> map = (HashMap<String, String>) client
				.getOperationMap();

		Iterator iter = map.entrySet().iterator();

		while (iter.hasNext()) {
			Map.Entry entry = (Map.Entry) iter.next();
			Object key = entry.getKey();

			// System.out.println("operation name and request name:" + key);
			// System.out.println( " Value : " + entry.getValue());
			// Object val = entry.getValue();
		}

		System.out
				.println("___________________________________________________");

		String xmlString = map.get("Put_Applicant|Request 1");

		System.out.println(xmlString);

		System.out
				.println("___________________________________________________");

		// get the xml string after that analysis it

		// using dom 4j to analysis

		SAXReader reader = new SAXReader();
		Document document = reader.read(new StringReader(xmlString));
		XMLFactory xmlFactory=new XMLFactory(document);
		
		XMLNode root=xmlFactory.getRootNode();
		
		System.out.println(root.getName());
		
		// client.generateWSDLRequest("Put_Applicant", "Request 1",
		// WorkDayPayload);
		//
		// client.setSecurity("hyang-impl@pwc_dpt1", "Underall1@",
		// "PasswordText");
		//
		// String Response = client.doSubmit();
		// System.out.println(Response);

		// Node node=
		// root.selectSingleNode("/soapenv:Envelope/soapenv:Body/bsvc:Put_Applicant_Request/bsvc:Applicant_Data/bsvc:Personal_Data/bsvc:Identification_Data/bsvc:National_ID");
		// System.out.println(node.getName());
	}

	

}
